refactor(aarch64,riscv64): unify kernel image detection#607
Conversation
mkroening
left a comment
There was a problem hiding this comment.
We already have similar code for RISC-V: https://github.com/hermit-os/loader/blob/v0.5.6/src/arch/riscv64/mod.rs#L21-L51
It might make sense to unify them as methods on an trait FdtExt, but that might not be worth the effort. You can decide. :)
|
Ah, I didn't even bother checking the RISC-V code. That one is also slightly prettier than this approach. I'll try the |
80527af to
baa7cc9
Compare
baa7cc9 to
3725077
Compare
|
CI on aarch64 fails because the fdt is... invalid as far as I can tell. |
This unifies the kernel image detection for both aarch64 and riscv64. riscv64 was incorrectly using the length of the module reg as the size of the kernel image, which was always 0, which is fixed by using the approach taken by the aarch64 code to parse the ELF header. On the other hand, aarch64 now falls back to linux,initrd-start and linux,initrd-end for detecting the kernel image thanks to these changes, which is necessary for cloud-hypervisor at the moment.
The generated devicetree contains #address-cells = <2> and #size-cells = <2>, which means that address and size are expected to be 64-bit values, but we were currently only constructing two 32-bit values, which meant that effectively, when parsing it, the size was missing. Fix it by making the values 64-bit wide.
3725077 to
5ce1b37
Compare
|
That's fixed now, we were the ones committing crimes with the devicetree in xtask :) |
This unifies the kernel image detection for both aarch64 and riscv64. riscv64 was incorrectly using the length of the module reg as the size of the kernel image, which was always 0, which is fixed by using the approach taken by the aarch64 code to parse the ELF header. On the other hand, aarch64 now falls back to linux,initrd-start and linux,initrd-end for detecting the kernel image thanks to these changes, which is necessary for cloud-hypervisor at the moment.